public class Test {
          public static void main(String[] args) {
              int arr[] = {1, 2, 3, 4, 5, 6, 7, 8};
              int j, k;
              for (int i : arr) {
                  System.out.print(i + "");
              }
              System.out.println();
              for (j = 0; j < arr.length; j++) {
                  if (arr[j] == 5) {
                      for (k = j; k < arr.length - 1; k++) {
                          arr[k] = arr[k + 1];
                      }
                      arr[k] = 0;
                  }
              }
              //鍒犻櫎
              for (int i : arr) {
                  System.out.print(i + "");
              }
              System.out.println();
              for (j = 0; j < arr.length; j++) {
                  if (arr[j] == 4) {
                      for (k = arr.length - 2; k >=j + 1;  k--) {
                          arr[k + 1] = arr[k];
                      }
                      arr[j + 1] = 5;
                  }
              }
              //娣诲姞5
              for (int i : arr) {
                  System.out.print(i + "");
              }
              System.out.println();
          }
      }

